<?php
    /**
     * CommonConfigBehavior is a behavior for the application.
     * It loads additional config parameters that cannot be statically 
     * written in config/main
     */
    class CommonConfigBehavior extends CBehavior{
        
        /**
         * Declares events and the event handler methods
         * See yii documentation on behavior
         */
        public function events()
        {
            return array_merge(parent::events(), array(
                'onBeginRequest'=>'beginRequest',
            ));
        }
     
        /**
         * Load configuration that cannot be put in config/main
         */
        public function beginRequest()
        {
           if (isset($_POST['LANG_CODE']))
                $this->owner->user->setState('LANG_CODE', $_POST['LANG_CODE']);
           if ($this->owner->user->getState('LANG_CODE'))
                $this->owner->language=$this->owner->user->getState('LANG_CODE');
           else
                $this->owner->language='VNI';
        }
    }
?>